
#include "VertexColorCube.h"
#include "GL/glew.h"
#include "GL/wglew.h"


VertexColorCube::VertexColorCube(float width, float length, float height):
	m_Width(width),
	m_Length(length),
	m_Height(height)
{
	float w = m_Width/2;
	float l = m_Length/2;
	float h = m_Height;

	m_ps[0].setValues(-w,-l,0);
	m_ps[1].setValues(-w,l,0);
	m_ps[2].setValues(w,l,0);
	m_ps[3].setValues(w,-l,0);

	m_ps[4].setValues(-w,-l,h);
	m_ps[5].setValues(-w,l,h);
	m_ps[6].setValues(w,l,h);
	m_ps[7].setValues(w,-l,h);


}


VertexColorCube::~VertexColorCube(void)
{
}

void VertexColorCube::Vertex(float3& v)
{
	glVertex3f(v.x,v.y,v.z);
}

void VertexColorCube::Draw()
{
	glBegin(GL_QUADS);
	// color blue for top and bottom face
	glColor3ub(0,0,255);
	Vertex(m_ps[0]); Vertex(m_ps[1]); Vertex(m_ps[2]); Vertex(m_ps[3]);
	Vertex(m_ps[7]); Vertex(m_ps[6]); Vertex(m_ps[5]); Vertex(m_ps[4]);

	// color red for positive X and negative X face
	glColor3ub(255,0,0);
	Vertex(m_ps[3]);Vertex(m_ps[2]);Vertex(m_ps[6]);Vertex(m_ps[7]);
	Vertex(m_ps[4]);Vertex(m_ps[5]);Vertex(m_ps[1]);Vertex(m_ps[0]);

	glColor3ub(0,255,0);
	Vertex(m_ps[5]);Vertex(m_ps[6]);Vertex(m_ps[2]);Vertex(m_ps[1]);
	Vertex(m_ps[0]);Vertex(m_ps[3]);Vertex(m_ps[7]);Vertex(m_ps[4]);

	glEnd();
}
